﻿using System.Windows.Controls;
using System.Windows.Navigation;
using Infragistics.Controls.Layouts;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System;

namespace StartupSolution.Views.Layouts.BuildingDockManager
{
    public partial class DockManagerCodeBehind : Page
    {
        public DockManagerCodeBehind()
        {
            InitializeComponent();
            Loaded += new System.Windows.RoutedEventHandler(DockManagerCodeBehind_Loaded);
        }

        void DockManagerCodeBehind_Loaded(object sender, System.Windows.RoutedEventArgs e)
        {
            // Create a dock manager instance
            XamDockManager dockManager = new XamDockManager();

            // ----------------------------------------
            // ----------------------------------------
            // Start of the SplitPane area
            
            // Create a SpliPane container located in the right side
            // Its children panes will be organized vertically.
            // This SplitPane contains a TabGroupPane and a ContentPane

            SplitPane splitPane = new SplitPane();
            splitPane.Location = XamDockLocation.Right;
            splitPane.Orientation = Orientation.Vertical;

            // Create a TabGroupPane container
            TabGroupPane tabGroupPane = new TabGroupPane();
            tabGroupPane.Location = XamDockLocation.Top;

            // Create Solution Explorer and Team Explorer panes to add as tabs in the TabGroupPane container
            ContentPane sExplorer = new ContentPane();
            sExplorer.Header = "Solution Explorer";
            sExplorer.IsActivePane = true;
            sExplorer.Image = new BitmapImage(new Uri("/StartupSolution;component/Images/img1.png",UriKind.Relative));

            ContentPane tExplorer = new ContentPane();
            tExplorer.Header = "Team Explorer";
            tExplorer.Image = new BitmapImage(new Uri("/StartupSolution;component/Images/img2.png", UriKind.Relative));

            tabGroupPane.Panes.Add(sExplorer);
            tabGroupPane.Panes.Add(tExplorer);

            // TODO: Add more ContentPanes as tabs in the TabGroupPane

            splitPane.Panes.Add(tabGroupPane);

            // Create Properties ContentPane
            ContentPane propertiesPane = new ContentPane();
            propertiesPane.Header = "Properties";
            propertiesPane.Location = XamDockLocation.Bottom;

            // Add newly created Properties ContentPane to the SplitPane container
            splitPane.Panes.Add(propertiesPane);
            dockManager.Panes.Add(splitPane);

            // TODO: Add more panes in the SplitPane 

            // ----------------------------------------
            // ----------------------------------------
            // End of the SplitPane area

            // ----------------------------------------
            // ----------------------------------------
            // Start of the TabGroupPane area at the bottom of the xamDockManager

            TabGroupPane bottomTgPane = new TabGroupPane();
            bottomTgPane.Location = XamDockLocation.Bottom;
            bottomTgPane.Height = 200;

            ContentPane outputPane = new ContentPane();
            outputPane.Header = "Output";
            outputPane.IsActivePane = true;

            bottomTgPane.Panes.Add(outputPane);

            // TODO: Add more ContentPanes

            /*
            ContentPane errorListPane = new ContentPane();
            errorListPane.Header = "Error List";

            ContentPane historyPane = new ContentPane();
            historyPane.Header = "History";

            bottomTgPane.Panes.Add(errorListPane);
            bottomTgPane.Panes.Add(historyPane);
            */
          
            dockManager.Panes.Add(bottomTgPane);
            // ----------------------------------------
            // ----------------------------------------
            // End of the TabGroupPane area at the bottom of the xamDockManager    

            
            // Create a documents area with the DocumentContentHost control
            DocumentContentHost docHost = new DocumentContentHost();

            // Documents are organized in a TabGroupPane
            TabGroupPane tgpHost = new TabGroupPane();

            // Add a document ContentPane
            ContentPane startPagePane = new ContentPane();
            startPagePane.Header = "Start Page";
            startPagePane.IsDocumentPane = true;

            // Add the ContentPane as a tab in the TabGroupPane
            tgpHost.Panes.Add(startPagePane);

            // Add the TabGroupPane in the DocumentContentHost control
            docHost.Panes.Add(tgpHost);

            // Add the DocumentContentHost control as xamDockManager Content
            dockManager.Content = docHost;

            LayoutRoot.Children.Add(dockManager);
            Grid.SetRow(dockManager, 2);
        }
    }
}
